package com.adjy.pathbuilders.rendering.loading;

import android.graphics.Bitmap;

/**
 * WeakReferenceBitmap is a container to redirect getBitmap calls to the
 * ImageFactory, so it can manage memory and allocations efficiently
 */
public class WeakReferenceBitmap {

	private ImageFactory factory;
	private String id;

	/**
	 * Creates a WeakReferencedBitmap based on the bitmapId given
	 * 
	 * @param factory
	 *            Factory to get Bitmaps from
	 * @param bitmapId
	 *            Bitmap ID
	 */
	public WeakReferenceBitmap(ImageFactory factory, String bitmapId) {
		this.factory = factory;
		this.id = bitmapId;
	}

	/**
	 * Gets the corresponded Bitmap based on the id
	 * 
	 * @return Bitmap from the ImageFactory
	 */
	public Bitmap getBitmap() {
		return factory.getImage(id);
	}

}
